package com.qhyt.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author jie
 * @date 2020/8/25 -11:32
 */
public class ListAndStringConvertUtil {

    public static String getStr(List<String> list) {

        StringBuilder workTypeStr = new StringBuilder();

        if (CollectionUtils.notEmpty(list)) {
            for (String workType : list) {
                workTypeStr.append(workType);
                if (list.size() - 1 != list.indexOf(workType)) {
                    workTypeStr.append(",");
                }
            }
        }
        return workTypeStr.toString();
    }

    public static List<String> getList(String str) {

        if (StringUtils.isNotEmpty(str)) {
            return Arrays.asList(str.split(","));
        }
        return new ArrayList<>();
    }
}
